import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2024/4/12-2024
 * @Description: 这里用一句话描述这个类的作用
 */
public class Test2 {
    public static void main1(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("abc");
        producer.setNamesrvAddr("117.72.8.31:9876");
        producer.setSendMsgTimeout(300000);

        producer.start();

        Message message = new Message("abc-topic", "abc", "abc", "消息".getBytes());
        SendResult send = producer.send(message);
        System.out.println(send);

    }

    public static void main(String[] args) throws Exception {
        File file=new File("E:\\test.txt");
        FileChannel fileChannel = new RandomAccessFile(file, "rw").getChannel();
        MappedByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 1024 * 1024);
        //mappedByteBuffer.compact();
        //mappedByteBuffer.flip();
        mappedByteBuffer.put("大美中国，我爱你".getBytes());
        Thread.sleep(100000);
        //ByteBuffer.allocate()
        //ByteBuffer.allocateDirect()
    }
}